<%@ page language="java" import="java.util.*,com.common.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">   
    <title>order_manage</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">  
	
	<link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
	<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>  
	<script type="text/javascript" src="js/jquery-1.8.0.js"></script> 
	
	<style type="text/css">
		.div_check{
			padding-left:20px;
			padding-top:5px;
			padding-bottom:5px;
			background:#D3EAEF;
			font-size:12px;
			font-weight:normal;
			height:25px;
		}
	</style>
	
	<script type="text/javascript">
		$(function(){
			$("#ch_checkall,#top_ch_checkall").click(function(){
				if(this.checked){
					$("input[name=ck_id]").attr("checked","checked");
				}else{
					$("input[name=ck_id]").removeAttr("checked");
				}		
			});
					
			$("table tr").mouseover(function(){
				$(this).css("background","#D3EAEF");
				$(this).siblings().css("background","white");
			});
		});
	</script>
	
  </head>
  
  <body>
	  <div class ="div_title">
			<div class="div_titlename"> <img src="images/san_jiao.gif" ><span>订单列表</span></div>
	  </div>
	  
	  <%
            request.setAttribute("orderStateList",Constant.EnumOrderSates.values());
      %>
	  
	  <form action="OrderServlet.do" method="post">
	  	<input type="hidden" name="flag" value="manage">
		<div class="div_check">
			订单号：<input type="text" name="orderNo" value="${param.orderNo }"> &nbsp;&nbsp;
			下单日期：从&nbsp;<input type="text" name="beginDate" onclick="WdatePicker()" value="${param.beginDate}" >&nbsp;到&nbsp;<input name="endDate"  onclick="WdatePicker()" value="${param.endDate}">
			订单状态：
			<select name="orderState">
				<option value="">请选择</option>
				<c:forEach var="state" items="${orderStateList }">
					<option value="${state }">${state }</option>
				</c:forEach>
			</select>&nbsp;
			<button value="submit">查询</button>
		</div>		 
	  	<table  class="main_table">
	  		<tr>
	  		    <th><input type="checkbox" id="ch_checkall" /></th>
	  			<th>订单号</th>
	  			<th>付款方式</th>
	  			<th>订单金额</th>
	  			<th>订单状态</th>
	  			<th>邮寄方式</th>
	  			<th>生成日期</th>
	  			<th>发货地址</th>
	  			<th>操作</th>
	  		</tr>
	  		
	  		<c:forEach var="order" items="${orderList }">
	 			<tr>
	 				<td>
	 					<input type="checkbox" name="ck_id" value="${order.id }" /> 
	 				</td>
	 				<td>${order.orderNo }</td>	
	 				<td>${order.payMethod }</td>	
	 				<td>${order.amount }</td>	
	 				<td>${order.orderState }</td>	
	 				<td>${order.postMethod }</td>	
	 				<td>${order.orderDate}</td>	
	 				<td>${order.address}</td>	
		 			<td>
		 			    <a href="OrderServlet.do?flag=show&id=${order.id }">查看</a>  | 
						<c:if test="${order.orderState=='已支付'}">
		 					<a href="OrderServlet.do?flag=send&id=${order.id }">发货</a> | 
		 				</c:if>
		 			</td>
	 			</tr>
	 		</c:forEach>
	  	</table>
	  	
	  	<div class="div_page" >
			  <div class="div_page_left">    共
			  	有 <label>${page.rowCount }</label> 条记录，当前第 <label>${page.pageIndex }</label> 页，共 <label>${page.pageCount }</label> 页	</div>		
			  <div class="div_page_right" > 	 
			  	<c:choose>
			  		<c:when test="${page.hasPre }">
			  			<a href="AdminServlet.do?flag=manage&pageIndex=1">首页</a>
			  			<a href="AdminServlet.do?flag=manage&pageIndex=${page.pageIndex-1 }">上一页</a>  &nbsp;  &nbsp;  &nbsp;  &nbsp;
			  		</c:when>
			  		<c:otherwise>
			  			 首页
		  	 			 上一页
			  		</c:otherwise>
			  	</c:choose>
			  	
			  	<c:choose>
			  		<c:when test="${page.hasNext }">
			  			<a href="AdminServlet.do?flag=manage&pageIndex=${page.pageIndex+1 }">下一页</a>
			  			<a href="AdminServlet.do?flag=manage&pageIndex=${page.pageCount }">尾页</a>  &nbsp;  &nbsp;  &nbsp;  &nbsp;
			  		</c:when>
			  		<c:otherwise>
			  			 下一页 
		  	 		   	尾页
			  		</c:otherwise>
			  	</c:choose>
	
		  	  <button onclick="javascript:subForm(${param.pageIndex})">转到</button>
		  	 <input type="text" name="pageIndex" id="pageIndex" value="${page.pageIndex }" /> 页
		  </div>	
		</div>
	</form>
	<script>
		 var str="${msg }";
		 if(str!=""){
			 alert(str);
		 }
	</script>
 
  </body>
</html>
